import java.io.IOException;
import java.net.SocketException;
import java.util.HashMap;
import java.util.Map;

public class UdpDictSever extends UdpEchoServer{
    // 使用一个集合来存放单词集合
    private Map<String,String> dict = new HashMap<>();

    public UdpDictSever(int port) throws SocketException {
        super(port);
        dict.put("cat","猫");
        dict.put("beautiful","美丽的");
        dict.put("perfect","完美的");
    }

    @Override
    public String process(String request){
        return dict.getOrDefault(request,"没有你要查的单词!");
    }

    public static void main(String[] args) throws IOException {
        UdpDictSever sever = new UdpDictSever(9090);
        sever.start();
    }
}
